<?php
/**
 * 为当前所在菜单项样式
 * @param  string $controller_name
 * @param  string $action_name
 * @param  string $style
 * @return string
 */
function activedLink($controller_name, $action_name, $style) {
    if (isset($action_name)
        && (false !== strpos($controller_name, CONTROLLER_NAME))
        && ACTION_NAME == $action_name) {
        return $style;
    }
    if (!isset($action_name)
        && (false !== strpos($controller_name, CONTROLLER_NAME))) {
        return $style;
    }

    return '';
}
/**
 * 为当前所在菜单项样式
 * @param  string $controller_name
 * @param  string $action_name
 * @param  string $style
 * @return string
 */
function subActivedLink($controller_name, $action_name, $style) {
    if(CONTROLLER_NAME == "Content" && ACTION_NAME == "index"){
        $arr = explode("?", $controller_name);
        $ids = explode("=", $arr[1]);
        //var_dump($ids[1]);
        if(!empty($ids[1]) && $ids[1] == I("get.id", NULL)){
            return $style;
        }else if(CONTROLLER_NAME . "/" . ACTION_NAME == $controller_name && I("get.id", NULL) === NULL){
            return $style;
        }
        return "";
    }
    if ((false !== strpos($controller_name, ACTION_NAME)) && (false !== strpos($controller_name, CONTROLLER_NAME))) {
        return $style;
    }

    return '';
}

/**
 * 得到gravatar头像
 * @param  string $email
 * @return string
 */
function getGravatar($email='') {
	return '/Public/admin/images/avatar.jpg';
    //return 'https://secure.gravatar.com/avatar/' . md5($email) . '.png';
}
